using UnityEngine;

namespace CinemaDirector
{
	[CutsceneItem("Light", "Set Light Colour")]
	public class SetLightColour : CinemaActorEvent
	{
		public Color Color;

		private Color cachedColor;

		private Color previousColor;

		public override void Initialize(GameObject actor)
		{
			Light component = actor.GetComponent<Light>();
			if (component != null)
			{
				previousColor = component.color;
				cachedColor = component.color;
			}
		}

		public override void Trigger(GameObject actor)
		{
			Light component = actor.GetComponent<Light>();
			if (component != null)
			{
				previousColor = component.color;
				component.color = Color;
			}
		}

		public override void Reverse(GameObject actor)
		{
			Light component = actor.GetComponent<Light>();
			if (component != null)
			{
				component.color = previousColor;
			}
		}

		public override void Stop(GameObject actor)
		{
			Light component = actor.GetComponent<Light>();
			if (component != null)
			{
				component.color = cachedColor;
			}
		}
	}
}
